﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

/// <summary>
/// Summary description for PanelData
/// </summary>
public class PanelData
{
    
	public PanelData()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    public bool add(PanelesEntities item)
    {
        bool flat = false;
        string[] parameters = { "@name", "@channel_id", "@control_url", "@cell_id", "@priority", "@category", "@display_all", "@display_container", "@file1", "@file2" };
        string[] values = {item._name,item._channelID.ToString(),item._control,item._cellID.ToString(),item._priority.ToString(),item._category.ToString(),item._displayAll,item._displayContainer,item._file1.ToString(),item._file2.ToString()};
        if (Database.getExecProcedure("sp_InsertPanel",parameters,values) > 0)
        {
            flat = true;
        }
        else
        {
            flat = false;
        }
        return flat;
    }
    public bool edit(PanelesEntities item)
    {
        bool flat = false;
        string[] parameters = {"@id", "@name", "@channel_id", "@control_url", "@cell_id", "@priority", "@category", "@display_all", "@display_container", "@file1", "@file2" };
        string[] values = {item._id.ToString(),item._name,item._channelID.ToString(),item._control,item._cellID.ToString(),item._priority.ToString(),item._category.ToString(),item._displayAll,item._displayContainer,item._file1.ToString(),item._file2.ToString()};
        if (Database.getExecProcedure("sp_UpdatePanel",parameters,values) > 0)
        {
            flat = true;
        }
        else
        {
            flat = false;
        }
        return flat;
    }
    public bool delete(int id)
    {
        bool flat = false;
        string[] parameters = {"@id" };
        string[] values = {id.ToString()};
        if (Database.getExecProcedure("sp_DeletePanel", parameters, values) > 0)
        {
            flat = true;
        }
        else
        {
            flat = false;
        }
        return flat;
    }

    public DataTable getPanel(int id)
    {
        return Database.getTable("exec sp_GetPanel '" + id.ToString() + "'");
    }
}
